<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" placeholder="请输入年份">
    <input type="text" placeholder="请输入月份">
    <input type="button" value="查询">
</body>
<script>
function getSumDay(year,month){
    switch (Number(month)){
        case 4:
        case 6:
        case 9:
        case 11:return 30;
        case 2:{
            if(year % 4 == 0 && year % 100 != 0|| year % 400 == 0){
                return 29
            }else{
                return 28
            }
        };
        default:{
            return 31
        }
    }
}
let inpArr = document.querySelectorAll('input')
inpArr[2].onclick = function(){
    let year = inpArr[0].value
    let month = inpArr[1].value
    let day = getSumDay(year,month)
    let msg = `${year}年${month}月一共有${day}天`
    alert(msg)
}

</script>
</html>